#pragma once
#include "../stdafx.h"
#include "../LogicEngine.h"

extern LPDIRECTINPUT8					g_pdInput;

#define MOUSE 0
#define KEYBOARD 1

	typedef struct
	{
		DWORD device;
		DWORD key;
		DWORD state;
	}INPUT_STR;

	enum ButtonState
	{
		Press,
		Up,
		Click,
		DoubleClick,
	};

	enum MouseType
	{
		LButton,
		MButton,
		RButton
	};

	enum KeyType
	{
		KeyEscape,
		Key1,
		Key2,
		Key3,
		Key4,
		Key5,
		Key6,
		Key7,
		Key8,
		Key9,
		Key0,
		KeyMinus,
		KeyEquals,
		KeyBack,
		KeyTab,
		KeyQ,
		KeyW,
		KeyE,
		KeyR,
		KeyT,
		KeyY,
		KeyU,
		KeyI,
		KeyO,
		KeyP,
		KeyLBracket,
		KeyRBracket,
		KeyReturn,
		KeyLControl,
		KeyA,
		KeyS,
		KeyD,
		KeyF,
		KeyG,
		KeyH,
		KeyJ,
		KeyK,
		KeyL,
		KeySemicolon,
		KeyApostrophe,
		KeyGrave,
		KeyLShift,
		KeyBackSlash,
		KeyZ,
		KeyX,
		KeyC,
		KeyV,
		KeyB,
		KeyN,
		KeyM,
		KeyComma,
		KeyPeriod,
		KeySlash,
		KeyRShift,
		KeyMultiply,
		KeyLMenu,
		KeySpace,
		KeyCapital,
		KeyF1,
		KeyF2,
		KeyF3,
		KeyF4,
		KeyF5,
		KeyF6,
		KeyF7,
		KeyF8,
		KeyF9,
		KeyF10,
		KeyNumLock,
		KeyScroll,
		KeyNumPad7,
		KeyNumPad8,
		KeyNumPad9,
		KeySubtract,
		KeyNumPad4,
		KeyNumPad5,
		KeyNumPad6,
		KeyAdd,
		KeyNumPad1,
		KeyNumPad2,
		KeyNumPad3,
		KeyNumPad0,
		KeyDecimal,
		KeyOEM_102,
		KeyF11,
		KeyF12,
		KeyF13,
		KeyF14,
		KeyF15,
		KeyKana,
		KeyABNT_C1,
		KeyConvert,
		KeyNoConvert,
		KeyYen,
		KeyABNT_C2,
		KeyNumPadEquals,
		KeyPrevTrack,
		KeyAt,
		KeyColon,
		KeyUnderLine,
		KeyKANJI,
		KeyStop,
		KeyAx,
		KeyUnlabeled,
		KeyNextTrack,
		KeyNumPadEnter,
		KeyRControl,
		KeyMute,
		KeyCalculator,
		KeyPlayPause,
		KeyMediaStop,
		KeyVolumeDown,
		KeyVolumeUp,
		KeyWebHome,
		KeyNumPadComma,
		KeyDivide,
		KeySysRQ,
		KeyRMenu,
		KeyPause,
		KeyHome,
		KeyUp,
		KeyPrior,
		KeyLeft,
		KeyRight,
		KeyEnd,
		KeyDown,
		KeyNext,
		KeyInsert,
		KeyDelete,
		KeyLWin,
		KeyRWin,
		KeyApps
	};

	class Mouse : public Component
	{
	public:
		Mouse(HWND);
		~Mouse();

		void addedToObject();

		HRESULT Init(HWND);
		
		void GetState(Message const& msg);
	private:
		bool MouseLeftClicked();
		bool MouseRightClicked();
		DIMOUSESTATE         m_mouseState;
		int32 m_mousePointX;
		int32 m_mousePointY;
		bool m_mouseLeftButton;
		bool m_mouseRightButton;
		LPDIRECTINPUTDEVICE8		m_mouseDevice;
	};

	class KeyBoard : public Component
	{
	public:
		KeyBoard(HWND);
		~KeyBoard();

		void addedToObject();
		HRESULT Init(HWND);
		void GetState(Message const& msg);
	private:
		bool m_key[132];
		bool GetKeyState(KeyType);
		LPDIRECTINPUTDEVICE8		m_keyboardDevice; 
	};
